﻿<navigation:Page x:Class="RIA.NTiersApp.Views.PruductListPage" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
                 xmlns:helpers="clr-namespace:RIA.NTiersApp.Helpers"
           Title="PruductListPage Page" 
                 xmlns:vm="clr-namespace:RIA.ViewModel;assembly=RIA.ViewModel" 
                 xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" 
                 xmlns:my="clr-namespace:RIA.DAL;assembly=RIA.ServicesLibrary"
                 xmlns:my1="clr-namespace:RIA.ServicesLibrary.Web.Services;assembly=RIA.ServicesLibrary" 
                 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
                 xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                 xmlns:extention="clr-namespace:RIA.NTiersApp.Extensions"
                 >
    <navigation:Page.Resources>
        <helpers:GifConverter x:Key="GifConverter" />
    </navigation:Page.Resources>
    <navigation:Page.DataContext>
        <vm:ProductListViewModel></vm:ProductListViewModel>
    </navigation:Page.DataContext>
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="65" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="Search for:" Width="68" VerticalAlignment="Center" Grid.ColumnSpan="2" Margin="5" />
            <TextBox Name="SearchTextBox"  Width="100" Grid.Column="1" VerticalAlignment="Center"  Margin="5" DataContext="{Binding}" Text="{Binding Path=Name, Mode=TwoWay}" />
            <Button Content="Search" x:Name="btnSearch"  Height="25"
                    CommandParameter="{Binding ElementName=SearchTextBox, Path=Text}" Command="{Binding Path=LoadProductListCommand}"></Button>
            <sdk:DataPager Height="26" Name="dataPager1" PageSize="10" Width="200"  Margin="5" Source="{Binding Path=DataList}" />
            <Button Content="AddNew" x:Name="btnAdd" Height="25" Click="btnAdd_Click"></Button>
        </StackPanel>
        <ListBox     Name="productListBox"
                     Margin="5" 
                     VerticalAlignment="Top"  Grid.Row="1" ItemsSource="{Binding Path=DataList}">
            <i:Interaction.Behaviors>
                <extention:ListBoxDoubleClickBehavior  DoubleClick="ListBoxDoubleClickBehavior_DoubleClick">
                    
                </extention:ListBoxDoubleClickBehavior>
            </i:Interaction.Behaviors>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Height="50">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Image Margin="2" Source="{Binding ThumbnailPhoto, Converter={StaticResource GifConverter}}" Grid.RowSpan="2" />
                        <TextBlock Name="NameField" Text="{Binding Name}" Margin="2" Grid.Row="0" Grid.Column="1" FontWeight="Bold" FontSize="12" />
                        <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1">
                            <TextBlock Text="Number:" Margin="2"  />
                            <TextBlock Text="{Binding Number}" Margin="2"  />
                            <TextBlock Text="| Category:" Margin="2"  />
                            <TextBlock Text="{Binding Category}" Margin="2" />
                            <TextBlock Text="| Price:" Margin="2"  />
                            <TextBlock Text="{Binding ListPrice, StringFormat=C}" Margin="2" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        
    </Grid>
</navigation:Page>
